import React, { useEffect, useState } from 'react'
import { useParams, useHistory } from 'react-router-dom';
import { getHDetail } from '../api/api';
import { Button } from 'antd-mobile'
import '../css/Detail.less'
type ParamsType = {
    id: string;
}
type data = {
    brief: string
    hospitalName: string
    id: number
    imgUrl: string
    level: number
}
export default function HospitalDetail() {
    const history = useHistory()
    const { id } = useParams<ParamsType>()
    const [list, setList] = useState<any>({})
    const getData = async (id: any) => {
        const data = await getHDetail(id)
        console.log(data);

        setList(data.data.data)
    }
    const toCard = () => {
        history.push('/outpatient/hospitalList/detail/' + id + '/card')
    }
    useEffect(() => {
        getData(id)
        console.log(list);

    }, [])
    if (list) {
        return <div>
            <h1>{list.hospitalName}</h1>
            <img style={{ 'width': '100%' }} src={'http://124.93.196.45:10001/' + list.imgUrl}></img>
            <Button onClick={() => { toCard() }} block color='primary' size='large'>
                预约门诊
            </Button>
        </div>
    } else {
        return <div></div>
    }
}
